﻿@implements IDisposable

<MudGrid>
	<MudItem md="12">
		<MudText id="GetElementById" Typo="Typo.h6" Align="Align.Center" Color="Color.Surface"></MudText>
	</MudItem>
	<MudItem md="12">
		@string.Join(" ", Result)
	</MudItem>
</MudGrid>

@code {

	private List<string> Result = new List<string>();

	protected override async Task OnAfterRenderAsync(bool firstRender)
	{
		if (firstRender)
		{
			try
			{
				await Task.Delay(1000);
				
				await Dom.QuerySelector("#GetElementById").TextAsync("Test 'QuerySelector'");

				await Task.Delay(1000);

				Result = await Dom.QuerySelector("#GetElementById").TextAsync();

				StateHasChanged();
			}
			catch (Exception ex)
			{
				Snackbar.Add($"{DashboardResource.StringError} : {ex.ToString()}", Severity.Error);
			}
		}
	}

	public async void Dispose() => await Dom.DisposeAsync();
}